<style>
    @media screen and (max-width: 500px) {
        .layui-table-view {
            width: 100% !important;
            overflow-x: scroll !important;
            left: 0 !important;
        }

        .layui-table-box {
            width:1000px !important;
            box-sizing: border-box;
        }
    }
</style>
<form class="layui-form seller-form" action="">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">手机号码：</label>
            <div class="layui-input-inline seller-inline-3">
                <input type="text" name="mobile" lay-verify="title" placeholder="请输入手机号码" autocomplete="off"
                       class="layui-input">
                <input type="hidden" id="user_id" value="{$user_id}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">类型：</label>
            <div class="layui-input-inline seller-inline-2">
                <select name="type" lay-verify="">
                    <option value=""></option>
                    <option value="1">消费</option>
                    <option value="2">退款</option>
                    <option value="3">充值</option>
                    <option value="4">提现</option>
                    <option value="5">佣金</option>
                    <option value="7">平台调整</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">变动时间：</label>
            <div class="layui-input-inline seller-inline-4">
                <input type="text" name="datetime" id="datetime" placeholder="开始时间 到 结束时间" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-sm" lay-submit lay-filter="export"><i class="iconfont icon-msnui-cloud-download" style="font-size: 20px !important;"></i>导出</button>
                <button class="layui-btn layui-btn-sm" lay-submit lay-filter="*"><i class="iconfont icon-chaxun"></i>筛选</button>
            </div>
        </div>
    </div>
</form>

<div class="table-body">
    <table id="balanceTable" lay-filter="balanceTable"></table>
</div>

<div id="export" style="display: none;">
    <form class="layui-form export-form" action="">
        <div class="layui-form-item">
            <div class="layui-margin-10">
                <blockquote class="layui-elem-quote layui-text">
                    请先筛选要导出的账户资金，默认导出全部
                </blockquote>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">任务名称：</label>
                <input type="text" name="taskname" lay-verify="title" style="width:200px;" placeholder="请输入任务名称" autocomplete="off" class="layui-input">
            </div>
        </div>
    </form>
</div>

<script>
    layui.use(['form', 'layedit', 'laydate', 'table'], function () {
        var laydate = layui.laydate;

        //时间插件
        laydate.render({
            elem: '#datetime',
            range: '到',
            format: 'yyyy-MM-dd'
        });

        layui.table.render({
            elem: '#balanceTable',
            height: 'full-220',
            cellMinWidth: '80',
            page: 'true',
            limit: '20',
            totalRow: true,
            user_id: 33,
            url: "{:url('balance/index')}?_ajax=1&user_id=" + $('#user_id').val(),
            id: 'balanceTable',
            cols: [[
                { type: 'numbers'},
                {
                    field: 'nickname', width: 140, title: '用户', align: 'center', templet: function (data) {
                        var html = '';
                        html += data.nickname;
                        return html;
                    }
                },
                { field: 'type', align: 'center', width: 120, title: '类型', totalRowText:'当前页合计：' },
                { field: 'money', align: 'center', width: 160, title: '金额', totalRow: true},
                { field: 'balance', align: 'center', width: 160, title: '余额' },
                { field: 'memo', align: 'center', title: '描述' },
                { field: 'ctime', align: 'center', width: 200, title: '时间' }
            ]]
        });
        layui.form.on('submit(*)', function (data) {
            layui.table.reload('balanceTable', {
                where: data.field
                , page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
        //会员导出
        layui.form.on('submit(export)', function (data) {
            layer.open({
                type: 1,
                title: '导出',
                area: ['400px', '290px'], //宽高
                btn: ['确定', '取消'],
                content: $("#export").html(),
                yes: function () {
                    //判断是否有选中
                    var filter = $(".seller-form").serialize();
                    $(".export-form:last").append("<input type='hidden' name='filter' value='" + filter + "'>");
                    var data = $(".export-form:last").serializeArray();
                    data.push({ 'name': 'model', 'value': 'Balance' });
                    JsPost("{:url('Ietask/export')}", data, function (res) {
                            layer.msg(res.msg, { time: 1500 }, function () {
                                if (res.status) {
                                    layui.table.reload('balanceTable');
                                    layer.closeAll();
                                }
                            });
                        }
                    );
                }, btn2: function () {
                    layer.closeAll();
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    });
</script>